//
//  PayResultVC.swift
//  BaseSwift
//
//  Created by gh on 2019/10/5.
//  Copyright © 2019 ghwang. All rights reserved.
//

import UIKit

class PayResultVC: UIViewController {

    var order:OrderVo?
    var type:String?
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.view.backgroundColor = UIColor.backgroundColor
        self.navigationView.setTitle("支付结果")
        
        let topView = UIView()
        topView.backgroundColor = UIColor.white
        view.addSubview(topView)
        let _ = topView.sd_layout()?.widthRatioToView(view,1)!.topSpaceToView(view,HT_StatusBarAndNavigationBarHeight)!.heightIs(235)
        
        let icon = UIImageView()
        icon.image = UIImage(named: "success")
        topView.addSubview(icon)
        let _ = icon.sd_layout()?.widthIs(48)!.heightIs(48)!.centerXEqualToView(topView)!.topSpaceToView(topView,20)
        
        let lab0 = UILabel()
        lab0.text = "支付成功"
        lab0.textAlignment = .center
        lab0.textColor = UIColor.textTitleColorBlack
        lab0.font = UIFont.systemFont(ofSize: 25,weight: UIFont.Weight(rawValue: 0.2))
        topView.addSubview(lab0)
        let _ = lab0.sd_layout()?.topSpaceToView(icon,10)!.heightIs(28)!.widthIs(105)!.centerXEqualToView(topView)
        
        let lab1 = UILabel()
        lab1.text = "实付￥\(self.order!.amountAll!)"
         lab1.textAlignment = .center
         lab1.textColor = UIColor.textPlaceHolderColor
         lab1.font = UIFont.smallFont
         topView.addSubview(lab1)
         let _ = lab1.sd_layout()?.topSpaceToView(lab0,15)!.heightIs(20)!.widthIs(155)!.centerXEqualToView(topView)
        
        let vline = UIView()
        topView.addSubview(vline)
        let _ = vline.sd_layout()?.widthIs(25)!.heightIs(10)!.centerXEqualToView(topView)!.topSpaceToView(lab1,15)
        
        let backBtn = UIButton()
        topView.addSubview(backBtn)
        backBtn.addTarget(self, action: #selector(goHome), for: .touchUpInside)
        backBtn.titleLabel?.font = UIFont.commonFontSmall
        backBtn.setTitle("返回首页", for: .normal)
        backBtn.setTitleColor(UIColor.tabbarDefaultTextColor, for: .normal)
        let _ = backBtn.sd_layout()?.widthIs(88)!.heightIs(28)!.rightSpaceToView(vline,16)!.topSpaceToView(lab1,15)
        backBtn.layer.borderColor = UIColor.lineColor.cgColor
        backBtn.layer.borderWidth = 1
        backBtn.sd_cornerRadius = SMALL_BTN_RADIUS
        
        let lookBtn = UIButton()
        lookBtn.addTarget(self, action: #selector(goOrder), for: .touchUpInside)

        topView.addSubview(lookBtn)
        lookBtn.titleLabel?.font = UIFont.commonFontSmall
        lookBtn.setTitle("查看订单", for: .normal)
        lookBtn.setTitleColor(UIColor.tabbarDefaultTextColor, for: .normal)
        let _ = lookBtn.sd_layout()?.widthIs(88)!.heightIs(28)!.leftSpaceToView(vline,16)!.topSpaceToView(lab1,15)
        lookBtn.layer.borderColor = UIColor.lineColor.cgColor
        lookBtn.layer.borderWidth = 1
        lookBtn.sd_cornerRadius = SMALL_BTN_RADIUS
        
        
        //支付成功通知
        API.payNotification(params: ["mobile":SPUtil.init().mobile ?? "",
                                     "orderNo":self.order!.orderNo!,
                                     "payType":self.type!]) { (result) in
                                        
                                        
        }
        
        
    }
    
    @objc func goHome(){
        
        APP.initMainVC()
        
    }
    @objc func goOrder(){
        
        PUSH(from: self, to: OrderViewController())
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
